﻿using RayDen.Library.Core;
using RayDen.Library.Core.Primitives;

namespace Lt.Engine.Types
{
    public class RayDifferential : Ray
    {
        internal bool hasDifferentials;
        internal Point rxOrigin, ryOrigin;
        internal Vector rxDirection, ryDirection, InvDir;
        internal float time;
        internal int depth;

        public RayDifferential(ref Point org, ref Vector dir, float t0 = 0.0001f, float t1 = 10000f)
            : base(ref org, ref dir, t0, t1)
        {
            time = 0f;
            depth = 0;
            InvDir = 1f / dir;
            hasDifferentials = false;
        }

        public RayDifferential(RayInfo vray)
            : base(vray)
        {
            hasDifferentials = false;
        }

        public void ScaleDifferentials(float s)
        {
            rxOrigin = Org + (rxOrigin - Org) * s;
            ryOrigin = Org + (ryOrigin - Org) * s;
            rxDirection = Dir + (rxDirection - Dir) * s;
            ryDirection = Dir + (ryDirection - Dir) * s;
        }
    }
}